package net.xdclass.controller;


import net.xdclass.controller.Request.ShortLinkAddRequest;
import net.xdclass.controller.Request.ShortLinkDelRequest;
import net.xdclass.controller.Request.ShortLinkPageRequest;
import net.xdclass.controller.Request.ShortLinkUpdateRequest;
import net.xdclass.service.ShortLinkService;
import net.xdclass.util.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 二当家小D
 * @since 2025-08-15
 */
@RestController
@RequestMapping("/api/link/v1")
public class ShortLinkController {
	@Autowired
	private ShortLinkService shortLinkService;

	@PostMapping("add")
	public JsonData addShortLink(@RequestBody ShortLinkAddRequest shortLinkAddRequest){
		JsonData jsonData = shortLinkService.addShortLink(shortLinkAddRequest);
		return jsonData;
	}
	@RequestMapping("pageByGroupId")
	public JsonData pageByGroupId(@RequestBody ShortLinkPageRequest shortLinkPageRequest){
		Map  map = shortLinkService.pageByGroupId(shortLinkPageRequest);
		return JsonData.buildSuccess(map);
	}
	@PostMapping("update")
	public JsonData update(@RequestBody ShortLinkUpdateRequest shortLinkUpdateRequest){
		JsonData jsonData = shortLinkService.update(shortLinkUpdateRequest);
		return jsonData;
	}
	@PostMapping("del")
	public JsonData del(@RequestBody ShortLinkDelRequest shortLinkDelRequest){
		JsonData jsonData = shortLinkService.delete(shortLinkDelRequest);
		return jsonData;
	}
}

